<!DOCTYPE html>
<html lang="en">

	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta charset="UTF-8">
		<title>优购优品网</title>
		<!-- <link rel="stylesheet" href="../css/themes/css/core.css">
    <link rel="stylesheet" href="../css/themes/css/icon.css">
    <link rel="stylesheet" href="../css/themes/css/home.css"> -->
		<link rel="stylesheet" type="text/css" href="../css/vant.css">
		<link rel="stylesheet" type="text/css" href="../css/vue-virtual-scroller.css">
		<link rel="stylesheet" type="text/css" href="../css/base.css" />
		<link rel="stylesheet" type="text/css" href="../css/local.css" />
		<script type="text/javascript" src="../script/jquery.js"></script>
		<script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
		<script type="text/javascript" src="../script/vue.min.js"></script>
		<script type="text/javascript" src="../script/vue-virtual-scroller.min.js"></script>
		<script type="text/javascript" src="../script/vant.min.js"></script>
		<script type="text/javascript" src="../script/fastclick.js"></script>
		<script type="text/javascript" src="../script/base.js"></script>

		<style>
			.van-sidebar-item {
				padding: 13px 12px 13px 9px;
			}

			.van-sidebar-item--select {
				color: #ee0a24;
			}

			.left {
				width: 80px;
				height: 100%;
				overflow-y: auto;
				background: #f8f8f8;
			}

			.right {
				position: absolute;
				left: 80px;
				right: 0;
				top: 0;
				height: 100%;
				overflow-y: auto;
				padding-right: 5px;
				background: #fff;
			}

			.right>div {
				height: 100%;
				overflow: hidden;
			}

			.right .row {
				position: relative;
			}

			.right .row .chexkbox {
				padding: 10px;
			}

			/* .right .row .img img {
            width: 100%;
            height: 100%;
        } */

			.right .row .desc {
				padding-left: 5px;
				padding-bottom: 5px;
			}

			.right .row .desc::after {
				position: absolute;
				box-sizing: border-box;
				content: ' ';
				pointer-events: none;
				top: -50%;
				right: -50%;
				bottom: -50%;
				left: -50%;
				border-bottom: 1px solid #ebedf0;
				-webkit-transform: scale(0.5);
				transform: scale(0.5);
			}

			.right .row .desc .title {
				font-size: 14px;
				/* height: 40px; */
				line-height: 20px;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
			}

			.right .row .desc .title .hot {
				color: #fff;
				background: #cd1b21;
				font-size: 12px;
				border-radius: 2px;
				margin-right: 5px;
				display: inline-block;
				line-height: 16px;
				padding: 0 2px;
				vertical-align: middle;
			}

			.tag {
				position: relative;
				overflow: hidden;
			}

			.tag>div {
				transform: scale(0.8);
				-webkit-transform-origin-x: 0;
				overflow: hidden;
				width: 128%;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.tag span {
				color: #cd1b21;
				border: 1px solid #ff6e73;
				font-size: 12px;
				border-radius: 2px;
				display: inline-block;
				line-height: 16px;
				padding: 0 2px;
				vertical-align: middle;
				margin-right: 4px;
				margin-bottom: 4px;
			}

			.right .row .desc .sub-title {
				font-size: 12px;
				color: #969799;
				line-height: 20px;
				height: 40px;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.right .row .desc .sub-title * {
				vertical-align: middle;
			}

			.banner {
				padding: 10px 10px 0 10px;

			}

			.banner>div {
				border-radius: 6px;
				overflow: hidden;
				background: #fdabab;
			}

			.banner img {
				width: 100%;
			}

			.price {
				color: #cd1b21;
				font-size: 18px;
			}

			.gwc {
				position: absolute;
				right: 0;
				bottom: 0;
				padding: 10px;
			}

			.cart {
				position: fixed;
				bottom: 30px;
				left: 20px;
				width: 50px;
				height: 50px;
				border-radius: 30px;
				overflow: hidden;
				background: rgba(0, 0, 0, .6);
				text-align: center;
				line-height: 44px;
			}

			.num {
				position: fixed;
				bottom: 65px;
				left: 65px;
				min-width: 16px;
				height: 16px;
				line-height: 16px;
				font-size: 12px;
				color: #fff;
				background: #cd1b21;
				border-radius: 16px;
				text-align: center;
				z-index: 11;
			}

			/* .van-popup {
            width: 70%;
            height: 100%;
        }

        .van-popup .filter-list {
            height: calc(100% - 44px);
            padding: 80px 0 20px 10px;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }

        .van-popup .filter-txt {
            line-height: 42px;
        }

        .van-popup .van-row {
            border-bottom: 1px solid #ebedf0;
            padding-bottom: 5px;
        }

        .van-popup .filter-condition {
            height: 26px;
            line-height: 26px;
            width: 80%;
            margin-bottom: 12px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        } */

			.van-search__content {
				border: 1px solid #cd1b21;
			}

			.van-search {
				background: transparent !important;
				padding: 0;
			}

			.van-nav-bar__title {
				margin: 0 50px 0 50px;
				max-width: none;
			}

			.van-nav-bar__left {
				height: 46px;
			}

			.head-right {
				height: 46px;
			}

			.scroller {
				height: 100%;
			}

			.scroller .van-cell {
				padding: 2px 12px;
			}

			.num-edit {
				position: absolute;
				bottom: 10px;
				right: 0;
			}

			.type {
				text-align: center;
				font-size: 12px;
				color: #424242;
			}

			.type img {
				height: 80px;
			}

			.mb {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				padding: 0 15px;
				font-size: 13px;
				color: #9e9e9e;
				height: 40px;
				line-height: 40px;
				background: #fff;
				z-index: 99;
			}

			.mb span {
				color: #cd1b21;
			}

			.p {
				padding: 15px;
				color: #9e9e9e;
			}

			.l .van-cell {
				font-size: 15px;
			}

			.c {
				text-align: right;
			}

			.c .c-p {
				font-size: 16px;
				color: #cd1b21;
			}

			.t {
				font-size: 13px;
				color: #9e9e9e;
				padding: 10px 15px;
			}

			.sq-m {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				background: rgba(255, 255, 255, 0.5);
			}

			.sq {
				position: absolute;
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
			}

			.sq img {
				position: absolute;
				left: 0;
				top: 0;
				width: 30px !important;
				height: 30px !important;
			}
		</style>

	</head>

	<body>
		<div id="app" v-cloak>
			<div class="init-full">

				<van-nav-bar class="head head-index" left-arrow @click-left="onClickLeft">
					<div slot="title" style="margin-top: 10px;">
						<form action="" style="margin-top:-3px;">
							<van-search placeholder="输入编码、品牌、品类、名称搜索" v-if="detailTypeList.length"
								v-model="detailTypeList[activeKey].keyName" shape="round"
								@search="getFilterList(detailTypeList[activeKey])">
							</van-search>
						</form>
					</div>
					<div slot="right">
						<div class="head-right">
							<van-icon name="shopping-cart-o" size="20px" @click="openCart"></van-icon>
						</div>
					</div>
				</van-nav-bar>

				<div class="body-no-bottom">
					<div class="content">


						<div class="left">
							<van-sidebar v-model="activeKey" @change="toggleItem">
								<van-sidebar-item :title="row.TagName" v-for="row in detailTypeList">
								</van-sidebar-item>
							</van-sidebar>
						</div>
						<div class="right">

							<div v-for="(row,i) in detailTypeList" v-show="i == activeKey">

								<div class="mb" v-if="row.isFinal">
									<span @click="returnBefore(row)">{{row.TagName}}&nbsp;</span>/
									<span v-if="row.selectTypeIndex == -1">&nbsp;搜索结果</span>
									<span
										v-if="row.selectTypeIndex != -1">&nbsp;{{row.typeNode[row.selectTypeIndex].Name}}</span>
								</div>


								<div class="type" v-if="!row.isFinal">
									<van-row>
										<van-col :span="8" v-for="(typeItem,typeIndex) in row.typeNode">
											<div @click="clickTypeHandler(row,typeItem,typeIndex)">
												<div v-if="typeIndex == 0"><img
														:src="shoppingMallServerIP + row.typeNode[1].Icon" /></div>
												<div v-if="typeIndex != 0"><img
														:src="shoppingMallServerIP + typeItem.Icon" /></div>
												<div>{{typeItem.Name}}</div>
											</div>

										</van-col>
									</van-row>
								</div>

								<div style="overflow: hidden;height:100%;padding-top: 40px;" v-if="row.isFinal">
									<van-pull-refresh :disabled="row.loadingDisabled" v-model="row.refreshLoading"
										@refresh="onRefresh(row)">
										<a-b class="scroller" :items="detailTypeList[activeKey].node"
											:min-item-size="59" key-field="ProductId" onscroll="listScroll(this)">
											<template v-slot="{ item,index,active }">
												<b-c :item="item" :size-dependencies="[item.BrandName,item.ProductName]"
													:data-index="index" :active="active">
													<van-cell @click="intoDetail(item)">
														<div class="row flex-box">

															<div class="desc flex-main">
																<div class="title">
																	{{item.ProductName}}
																</div>
																<div style="font-size: 14px;color:#9e9e9e;">
																	货号：{{item.ProductCode}}</div>
																<div class="price" v-show="userInfo">
																	<span
																		style="font-size: 12px;">￥</span>{{item.SalePrice}}
																</div>

															</div>
															<div class="chexkbox" @click.stop="toggleChecked(item,row)"
																v-show="userInfo">
																<van-checkbox v-model="item.checked"
																	checked-color="#cd1b21">
																</van-checkbox>
															</div>
															<div class="num-edit" v-if="item.checked" @click.stop="">
																<van-stepper v-model="item.num" integer
																	:step="item.StepNum" :min="item.StepNum"
																	:max="item.Stock"
																	:disable-input="item.StepNum > 1?true:false"
																	@change="changeCheckNum(item,row)">
																</van-stepper>
															</div>


															<div class="sq-m" v-if="item.Stock <= 0">
																<div class="sq"><img src="../image/sq.png" /></div>
															</div>
														</div>
													</van-cell>

												</b-c>
											</template>
										</a-b>

									</van-pull-refresh>
								</div>


								<van-popup v-model="row.showFilter" position="right" :overlay="true"
									:lazy-render="false" :overlay-style="{'position':'fixed','left':0}">
									<div class="filter-list">
										<div class="filter-txt">品牌</div>
										<div>
											<van-row>
												<van-col span="8" v-for="(item,index) in brands">
													<van-button size="mini" class="filter-condition"
														:type="getFilterColor(item.Value,row.brandId)"
														@click="toggleFilter(item.Value,'brandId',row)">{{item.Name}}
													</van-button>
												</van-col>
											</van-row>
										</div>
									</div>
									<div>
										<van-button type="primary" block style="border-radius: 0;"
											@click="getFilterList(row)">筛选
										</van-button>
									</div>
								</van-popup>

							</div>


						</div>

					</div>
					<van-loading v-if="showLoading" />
				</div>
				<div class="bottom" v-show="userInfo">
					<van-submit-bar :price="getTotalPrice()" :loading="ifConfirm" @submit="onSubmit" button-text="确定">
						<van-checkbox checked-color="#cd1b21" v-model="allChecked" @change="changeAll">全选</van-checkbox>
					</van-submit-bar>
				</div>
			</div>


			<van-popup v-model="showCheckedArray" style="border-radius: 8px;" :style="{width:'80%'}">
				<div class="p">清单汇总</div>
				<div class="l">
					<van-cell-group>

						<van-cell v-for="(row,index) in detailTypeList" v-if="row.checkArray.length">
							<div class="row flex-box">

								<div class="desc flex-main">
									<div class="title">
										{{row.TagName}}
									</div>

								</div>
								<div class="c">

									<div>{{row.checkArray.length}}种&nbsp;/&nbsp;{{getCheckedTotalNum(row)}}件</div>
									<div class="c-p">￥{{getCheckedTotalPrice(row)}}</div>
								</div>

							</div>
						</van-cell>





					</van-cell-group>
				</div>
				<div class="t">合计<span style="font-size: 15px;color: #cd1b21;">￥{{getTotalPrice_popup()}}</span></div>
				<div style="padding: 10px;">
					<van-row gutter="20">
						<van-col span="12">
							<van-button type="default" block @click="addCart">加入购物车</van-button>
						</van-col>
						<van-col span="12">
							<van-button type="primary" block @click="buyNow">立即下单</van-button>
						</van-col>
					</van-row>
				</div>
			</van-popup>


		</div>



	</body>

	<!-- 调用 uniapp webview 的 api ，记得需要写在 body 标签下面 -->
	<script src="../../../assets/script/uni.webview.1.5.4.js"></script>
	<script type="text/javascript">
		var vm;

		function listScroll(that) {
			if ($(that).scrollTop() == 0) {
				vm.detailTypeList[vm.activeKey].loadingDisabled = false;
			} else {
				vm.detailTypeList[vm.activeKey].loadingDisabled = true;
			}
		}

		//$('.init-full').show();

		var userInfo = FLD.getUserInfo();

		Vue.use(vant.Lazyload, {
			loading: '../image/no.png',
			error: '../image/no.png'
		});


		Vue.component('a-b', VueVirtualScroller.DynamicScroller)
		Vue.component('b-c', VueVirtualScroller.DynamicScrollerItem)

		// var tabKey = api.pageParam.tabKey;
		// var tabKey = JSON.parse(window.localStorage.getItem('tabKey'));

		vm = new Vue({
			el: '#app',
			data: {
				showLoading: false,
				ifConfirm: false,
				serverIP: 'http://' + FLD.serverIP,
				shoppingMallServerIP: 'http://' + FLD.shoppingMallServerIP,
				activeKey: 0,
				cartNum: 0,
				detailTypeList: [],
				types: [],
				brands: [],
				allChecked: false,
				userInfo: FLD.getUserInfo() || '',
				showCheckedArray: false
			},
			created: function() {
				var that = this;

				var appTop = parseInt(window.localStorage.getItem('safeAreaTop'));

				if (appTop) {
					$('.head-index').css({
						'padding-top': appTop + 'px',
						'height': appTop + 50 + 'px',
						'line-height': '40px'
					})
				}


				that.getBrands();
				// that.getCartNum();
				that.getMeal();
			},
			methods: {
				GetActiveKey(data) {
					var that = this;
					that.activeKey = data;
					// console.log(data)
				},
				getCheckedTotalNum(row) {
					var num = 0;
					for (var i in row.checkArray) {
						num += row.checkArray[i].num
					}
					return num;
				},
				getCheckedTotalPrice(row) {
					var price = 0;
					for (var i in row.checkArray) {
						price += row.checkArray[i].num * row.checkArray[i].SalePrice;
					}
					return price.toFixed(2);
				},
				toggleNodeChecked(row) {
					var that = this;
					// console.log(JSON.stringify(row.checkArray))
					for (var i in row.node) {
						for (var j in row.checkArray) {
							if (row.node[i].ProductId == row.checkArray[j].ProductId) {
								that.$set(row.node[i], 'checked', true);
								row.node[i].num = row.checkArray[j].num;
							}
						}
					}
				},
				getTypes() {
					var that = this;
					FLD.ajax('sp_allProductType', {}, function(res) {
						that.types.push({
							Name: '所有',
							Value: 0
						})
						var scp = [];
						var kqlq = [];
						var jylq = [];
						var ktlq = [];
						var hhs = [];
						// console.log(JSON.stringify(res.ds))
						for (var i in res.ds) {
							if (res.ds[i].Name == '刹车片') {
								scp.push({
									CategoryId: res.ds[i].CategoryId,
									Name: '全部',
									Icon: ''
								})
								for (var j in res.ds) {
									if (res.ds[i].CategoryId == res.ds[j].ParentCategoryId && res.ds[j]
										.Name != '日韩刹车' && res.ds[j].Name != '欧系刹车' && res.ds[j].Name !=
										'美系刹车' && res.ds[j].Name != '国产刹车') {
										scp.push(res.ds[j]);
									}
								}
							}
							if (res.ds[i].Name == '空气滤清器') {
								kqlq.push({
									CategoryId: res.ds[i].CategoryId,
									Name: '全部',
									Icon: ''
								})
								for (var j in res.ds) {
									if (res.ds[i].CategoryId == res.ds[j].ParentCategoryId) {
										kqlq.push(res.ds[j]);
									}
								}
							}
							if (res.ds[i].Name == '机油滤清器') {
								jylq.push({
									CategoryId: res.ds[i].CategoryId,
									Name: '全部',
									Icon: ''
								})
								for (var j in res.ds) {
									if (res.ds[i].CategoryId == res.ds[j].ParentCategoryId) {
										jylq.push(res.ds[j]);
									}
								}
							}
							if (res.ds[i].Name == '空调滤清器') {
								ktlq.push({
									CategoryId: res.ds[i].CategoryId,
									Name: '全部',
									Icon: ''
								})
								for (var j in res.ds) {
									if (res.ds[i].CategoryId == res.ds[j].ParentCategoryId) {
										ktlq.push(res.ds[j]);
									}
								}
							}
							if (res.ds[i].Name == '火花塞') {
								hhs.push({
									CategoryId: res.ds[i].CategoryId,
									Name: '全部',
									Icon: ''
								})
								for (var j in res.ds) {
									if (res.ds[i].CategoryId == res.ds[j].ParentCategoryId) {
										hhs.push(res.ds[j]);
									}
								}
							}

						}

						for (var i in that.detailTypeList) {
							if (that.detailTypeList[i].TagName.indexOf('刹车片') > -1) {
								that.detailTypeList[i].typeNode = scp;
							}
							if (that.detailTypeList[i].TagName.indexOf('空气滤清') > -1) {
								that.detailTypeList[i].typeNode = kqlq;
							}
							if (that.detailTypeList[i].TagName.indexOf('机油滤清') > -1) {
								that.detailTypeList[i].typeNode = jylq;
							}
							if (that.detailTypeList[i].TagName.indexOf('空调滤清') > -1) {
								that.detailTypeList[i].typeNode = ktlq;
							}
							if (that.detailTypeList[i].TagName.indexOf('火花塞') > -1) {
								that.detailTypeList[i].typeNode = hhs;
							}
						}

					})
				},
				getBrands() {
					var that = this;
					FLD.ajax('sp_getBrand', {}, function(res) {
						that.brands.push({
							Name: '所有',
							Value: 0
						})
						for (var i in res.ds) {
							that.brands.push({
								Name: res.ds[i].BrandName,
								Value: res.ds[i].BrandId
							})

						}
					})
				},
				getFilterColor(name, value) {
					var that = this;
					if (name == value) {
						return 'primary';
					} else {
						return 'default';
					}
				},
				toggleFilter(name, value, row) {
					var that = this;
					row[value] = name;


				},
				toggleChecked(item, row) {
					var that = this;
					if (typeof item.checked === 'undefined') {
						that.$set(item, 'checked', true);
						row.checkArray.push(item);
					} else {
						item.checked = !item.checked;
						if (item.checked) {
							row.checkArray.push(item);
						} else {
							row.checkArray = row.checkArray.filter(function(a) {
								return a.ProductId != item.ProductId;
							})
						}

					}
				},
				changeCheckNum(item, row) {
					for (var i in row.checkArray) {
						if (row.checkArray[i].ProductId == item.ProductId) {
							row.checkArray[i].num = item.num;
						}
					}
				},
				getCartNum() {
					var that = this;
					FLD.ajax('sp_getShipCarts', {}, function(res) {
						that.showLoading = false;
						var cartNum = 0;
						for (var i in res.ds) {
							cartNum += res.ds[i].Quantity;
						}
						that.cartNum = cartNum;
					})
				},
				getMeal() {
					var that = this;
					that.showLoading = true;
					FLD.ajax('sp_getTcTags', {}, function(res) {
						that.showLoading = false;
						var detailTypeList = []
						for (var i in res.ds) {
							detailTypeList.push({
								listLoading: false,
								listFinished: true,
								pageIndex: 1,
								pageSize: 999,
								node: [],
								TagID: res.ds[i].TagID,
								TagName: res.ds[i].TagName,
								keyName: '',
								categoryId: 0,
								brandId: 0,
								showFilter: false,
								loadingDisabled: false,
								refreshLoading: false,
								typeNode: [],
								ifFinal: false,
								selectTypeIndex: -1,
								checkArray: []
							})
						}

						that.detailTypeList = detailTypeList;

						that.getTypes();

					})
				},
				getFilterList(row) {
					var that = this;
					that.showLoading = true;
					that.allChecked = false;
					row.showFilter = false;
					row.isFinal = true;
					row.pageIndex = 1;
					var obj = {
						keyName: row.keyName,
						categoryId: row.selectTypeIndex == -1 ? row.categoryId : row.typeNode[row.selectTypeIndex]
							.CategoryId,
						brandId: row.brandId,
						tagId: row.TagID,
						pageIndex: row.pageIndex,
						pageSize: row.pageSize
					}
					FLD.ajax('sp_searchProducts', obj, function(res) {
						that.showLoading = false;
						row.refreshLoading = false;
						row.listFinished = false;
						for (var i in res.ds) {
							res.ds[i].num = res.ds[i].StepNum;
						}
						row.node = res.ds;
						that.toggleNodeChecked(row);
					})
				},
				returnBefore(row) {
					var that = this;

					row.node = [];
					row.keyName = '';
					row.pageIndex = 1;
					row.selectTypeIndex = -1;
					row.isFinal = false;
					that.allChecked = false;
				},
				onRefresh(row) {
					var that = this;
					row.refreshLoading = true;
					if (row.selectTypeIndex == -1) {
						that.getFilterList(row)
					} else {
						that.clickTypeHandler(row, row.typeNode[row.selectTypeIndex], row.selectTypeIndex);
					}

				},
				clickTypeHandler(row, typeItem, typeIndex) {
					var that = this;
					that.showLoading = true;
					row.isFinal = true;
					row.selectTypeIndex = typeIndex;
					row.pageIndex = 1;
					var obj = {
						keyName: row.keyName,
						categoryId: typeItem.CategoryId,
						brandId: row.brandId,
						tagId: row.TagID,
						pageIndex: row.pageIndex,
						pageSize: row.pageSize
					}
					FLD.ajax('sp_searchProducts', obj, function(res) {
						that.showLoading = false;
						row.refreshLoading = false;
						row.listFinished = false;
						for (var i in res.ds) {
							res.ds[i].num = res.ds[i].StepNum;
						}
						row.node = res.ds;
						that.toggleNodeChecked(row);
					})

				},
				toggleItem(row) {
					var that = this;
					that.allChecked = false;

				},
				getTagArray(item) {
					var that = this;
					if (!item.TagNames) {
						return [];
					} else {
						return item.TagNames.split(',');
					}
				},
				getTotalPrice() {
					var that = this;
					var m = 0;
					for (var x in that.detailTypeList) {
						for (var i in that.detailTypeList[x].checkArray) {
							m += that.detailTypeList[x].checkArray[i].SalePrice * that.detailTypeList[x].checkArray[i]
								.num;
						}
					}

					return m * 100;
				},
				getTotalPrice_popup() {
					var that = this;
					var m = 0;
					for (var x in that.detailTypeList) {
						for (var i in that.detailTypeList[x].checkArray) {
							m += that.detailTypeList[x].checkArray[i].SalePrice * that.detailTypeList[x].checkArray[i]
								.num;
						}
					}

					return m.toFixed(2);
				},
				changeAll(v) {
					var that = this;
					if (that.detailTypeList[that.activeKey].isFinal) {
						if (v) {
							for (var i in that.detailTypeList[that.activeKey].node) {
								if (that.detailTypeList[that.activeKey].node[i].Stock > 0) {
									that.$set(that.detailTypeList[that.activeKey].node[i], 'checked', true);
								} else {
									that.$set(that.detailTypeList[that.activeKey].node[i], 'checked', false);
								}

							}
							that.detailTypeList[that.activeKey].checkArray = JSON.parse(JSON.stringify(that
								.detailTypeList[that.activeKey].node)).filter(function(x) {
								return x.checked;
							});
						} else {
							for (var i in that.detailTypeList[that.activeKey].node) {
								that.$set(that.detailTypeList[that.activeKey].node[i], 'checked', false);
							}
							that.detailTypeList[that.activeKey].checkArray = [];
						}
					}

				},
				addCart() {
					var that = this;
					that.showCheckedArray = false;

					var productIds = [];
					var skuIds = [];
					var quantitys = [];
					for (var x in that.detailTypeList) {
						for (var i in that.detailTypeList[x].checkArray) {
							productIds.push(that.detailTypeList[x].checkArray[i].ProductId)
							skuIds.push(that.detailTypeList[x].checkArray[i].SkuId)
							quantitys.push(that.detailTypeList[x].checkArray[i].num)

						}
					}
					var obj = {
						productId: productIds.join(),
						skuId: skuIds.join(),
						quantity: quantitys.join()
					}
					FLD.nativeRequest_shop('batchAddShoppingCar', obj, function(res) {

						for (var x in that.detailTypeList) {
							that.detailTypeList[x].checkArray = [];
							for (var i in that.detailTypeList[x].node) {

								that.$set(that.detailTypeList[x].node[i], 'checked', false);
							}
						}
						that.allChecked = false;

						layer.open({
							content: '购物车添加成功!',
							skin: 'msg',
							time: 2
						});
					})



				},
				buyNow() {
					var that = this;
					that.showCheckedArray = false;
					var commodityList = [];
					for (var x in that.detailTypeList) {
						for (var i in that.detailTypeList[x].checkArray) {
							commodityList.push({
								productId: that.detailTypeList[x].checkArray[i].ProductId,
								quantity: parseInt(that.detailTypeList[x].checkArray[i].num),
								price: parseFloat(that.detailTypeList[x].checkArray[i].SalePrice).toFixed(2),
								skuId: that.detailTypeList[x].checkArray[i].SkuId,
								image: that.detailTypeList[x].checkArray[i].ThumbnailUrl160,
								name: that.detailTypeList[x].checkArray[i].ProductName
							})

						}
					}


					if (commodityList.length) {

						for (var x in that.detailTypeList) {
							that.detailTypeList[x].checkArray = [];
							for (var i in that.detailTypeList[x].node) {

								that.$set(that.detailTypeList[x].node[i], 'checked', false);
							}
						}
						that.allChecked = false;

						api.openWin({
							name: 'submitOrder',
							url: 'submitOrder.html',
							reload: true,
							slidBackEnabled: false,
							pageParam: {
								commodityList: commodityList,
								formType: '套餐'
							}
						})
					}
				},
				onSubmit() {
					var that = this;

					that.showCheckedArray = true;

					// for (var i in that.detailTypeList[that.activeKey].node) {
					//     if (that.detailTypeList[that.activeKey].node[i].checked) {
					//         var obj = {
					//             productId: that.detailTypeList[that.activeKey].node[i].ProductId,
					//             skuId: that.detailTypeList[that.activeKey].node[i].SkuId,
					//             quantity: 1
					//         }
					//         FLD.ajax('sp_addShoppingCarts', obj, function (res) {

					//         })
					//     }

					// }

					// return;











				},
				openCart() {
					var that = this;
					FLD.mustLogin(function() {
						api.openWin({
							name: 'shoppingCart',
							url: 'shoppingCart.html',
							reload: true,
							slidBackEnabled: false
						})
					})
				},
				intoDetail(row) {
					var that = this;

					window.localStorage.setItem('productData', JSON.stringify(row))
					window.localStorage.setItem('stepIndex', JSON.stringify(1))
					window.location.href = './product.html'
					// api.openWin({
					// 	name: 'product',
					// 	url: 'product.html',
					// 	reload: true,
					// 	slidBackEnabled: false,
					// 	pageParam: {
					// 		productData: row,
					// 		stepIndex: 1
					// 	}
					// })
				},
				keybackEvent() {
					var that = this;
					if (that.detailTypeList[that.activeKey].typeNode.length && that.detailTypeList[that.activeKey]
						.isFinal) {
						that.returnBefore(that.detailTypeList[that.activeKey]);
					} else {
						// vm.GoBack()
						uni.navigateBack()
					}
				},
				GoBack() {
					window.localStorage.removeItem('tabKey')
					window.history.back()
				},
				onClickLeft() {
					var that = this;
					uni.navigateBack()
					// that.keybackEvent();
				}
			}
		})
	</script>

</html>